//
//  ViewController.m
//  HQQNetworkExemple
//
//  Created by 黄强强 on 16/7/7.
//  Copyright © 2016年 黄强强. All rights reserved.
//

#import "ViewController.h"
#import "HQQNetwork.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextView *textView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 1. 设置环境
    [HQQAPIGenerator sharedGenerator].isTestMode = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"APITestMode"] boolValue];
    [HQQAPIGenerator sharedGenerator].defaultProtocol = @"https";
    
    // 2. 发送请求
    NSString *url = [[HQQAPIGenerator sharedGenerator] API:@"common/get_domain"];
    
    [[HQQNetworkManager sharedManager] GET:url paramters:@{} responseClass:nil success:^(NSInteger status, NSString *message, id response) {
        
        NSString *res = [NSString stringWithFormat:@"%@\n\n%@",url,response];
        self.textView.text = res;
        
    } failure:^(NSError *error) {
        
        NSString *res = [NSString stringWithFormat:@"%@\n\n%@",url,error.description];
        self.textView.text = res;
        
    }];
}

@end
